package com.example.springcloudmodelserver.service;

import com.example.springcloudmodelserver.Dao.Modeldao;
import com.example.springcloudmodelserver.entity.Model;
import com.example.springcloudmodelserver.entity.ModelTest;
import com.example.springcloudmodelserver.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Modelservice {

    @Autowired
    private Modeldao modeldao;
    //根据模型id查询模型表
    public Model queryModelByModelid(String modelid){return modeldao.selectModelByModelid(modelid);}
    //根据模型名称查询模型表
    public Model queryModelByModelname(String modelname){return modeldao.selectModelByModelname(modelname);}
    //根据真实姓名查询用户表
    public User queryUserByTruename(String truename){return modeldao.selectUserByTruename(truename);}
    //根据用户名查询用户表
    public User queryUser(String username) {return modeldao.selectUserByusername(username);}
    //根据用户名查询模型表
    public Model queryModel(String username) {return modeldao.selectModelByusername(username);}
    //查询filemd5
    public Model queryModelByFileMD5(String filemd5){return modeldao.selectModelByMD5(filemd5);}
    //插入模型信息
    public void addModel(Model model){
        modeldao.insertModel(model.getModelname(),model.getPatentnum(),model.getModeltype(),model.getUpdatetime(),model.getPrice(),model.getUsername(),model.getLanguage(),model.getHardware(),model.getSoftware(),model.getFrame(),model.getRely());
    }
    //更新模型开发者资质
    public void updateModelIdentity (String username,String truename,String identityinfo,String identitypath) {modeldao.updateIdentityByuser(username,truename,identityinfo,identitypath);}
    //更新文件上传路径
    public void updateModelFilepath(String modelid,String filepath) {modeldao.updateModelfile(modelid,filepath);}
    //更新上传文件MD5
    public void updateModelFileMD5(String modelid,String filemd5){modeldao.updateFileMD5(modelid,filemd5);}
    //更新上传信息
    public void updateModel(Model model){
        modeldao.updateModel(model.getModelname(),model.getPatentnum(),model.getModeltype(),model.getUpdatetime(),model.getUsername(),model.getLanguage(),model.getHardware(),model.getSoftware(),model.getFrame(),model.getRely());
    }
    //更新模型功能说明书路径
    public void updatefunpath(String modelid,String funpath) {
        modeldao.updatefunpath(modelid,funpath);
    }
    //删除模型
    public void deleteModel(String modelname){
        modeldao.deleteModelByModelname(modelname);
    }
}
